﻿using System;
using System.Windows.Forms;
using Tools;

namespace Admin.登录
{
    public partial class 管理员登录 : Form
    {
        Models.Admin_1 m_user = new Models.Admin_1();
        BLL.B_Admin b_user = new BLL.B_Admin();

        public 管理员登录()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                Models.Admin_1 m_admin = new Models.Admin_1();
                m_admin.admin_uname = textBox1.Text;

                // password hack
                m_admin.pwd = MD5Provider.Hash(textBox2.Text);

                BLL.B_Admin b_admin = new BLL.B_Admin();
                if (b_admin.Login(m_admin) == 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {                   
                    throw new Exception("用户名或密码错误"); 
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
    }
}
